import sys
import os

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),'..','..','modules')))
import mods


def index(req):
	web = mods.Web(req)

	dbConnection = mods.GetDBConnection()
	cursor = dbConnection.cursor()

	web.Header()

	web.Write("""<h2>Public Holidays</h2>""")


	web.Write("""<table class="grid">""")
	web.Write("""<tr><th>Public Holiday</th><th>Date</th><th>Non Working Day</th></tr>""")

	cursor.execute("""SELECT holiday_date, non_working_day, holiday FROM public_holidays ORDER BY holiday_date""")
	for record in cursor.fetchall():
		(holidayDate, nonWorkingDay, holiday) = record
		web.Write("""<tr>""")
		web.Write("""<td style="text-align: left;">%s</td>""" % (holiday))
		web.Write("""<td>%s</td>""" % (holidayDate))
		web.Write("""<td>%s</td>""" % (nonWorkingDay))
		web.Write("""</tr>""")
	web.Write("""</table><br />""")


	web.Footer()


